package com.itgaohe.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itgaohe.dao.entity.Shop;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShopDao extends BaseMapper<Shop> {

    /*
     * 根据类型ID分页查询商铺
     */
    @Select("SELECT * FROM tb_shop " +
            "WHERE type_id = #{typeId} " +
            "AND cursor_index < #{cursor} " +
            "AND is_deleted = 0 " +
            "ORDER BY cursor_index DESC LIMIT 7")
    List<Shop> selectShopByType(
            @Param("typeId") Long typeId,
            @Param("cursor") Long cursor);

    /*
     * 分页查询所有商铺
     */
    @Select("SELECT * FROM tb_shop " +
            "WHERE cursor_index < #{cursor} " +
            "AND is_deleted = 0 " +
            "ORDER BY cursor_index DESC LIMIT 7")
    List<Shop> queryAllShops(@Param("cursor") Long cursor);
}
